function addLoadEvent(func) {
    var oldonLoad = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function () {
            oldonload();
            func();
        }
    }
}


//        获取选择器元素

function getId(selector) {
    var ele = document.querySelector(selector);
    return ele;
}

function getClass(selector) {
    var ele = document.querySelectorAll(selector);
    return ele;
}

function getTagName(selector) {
    var ele = document.getElementsByTagName(selector);
    return ele;
}

function checkLogin(fname) {
    var form = document.forms[fname],
        userName = form["user"],
        pwd = form["pwd"],
        pwd2 = form["pwd2"],
        btn = form["btn"];
    btn.onclick = function () {
        if (userName.value === "" || pwd.value === "") {
            alert("请输入用户名或密码");
            return false;
        } else if (pwd.value !== pwd2.value) {
            alert("两次密码不一致");
            return false;
        }
    }
}